Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime field script params #202

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

alejokf
Copy link
Contributor

@alejokf alejokf commented Apr 18, 2024

Issue

resolves #201

Goal

Add support for Elasticsearch lang and params fields in runtime_mappings' script

Usage

This Typescript code:

const params = {
   factor: 2
}
const field = esb.runtimeField("long", "emit(doc['measure'].value * params.factor);")
  .lang('painless')
  .params(params)
const reqBody = esb.requestBodySearch();
reqBody.runtimeMapping('measure', field);

Will generate this query:

{
  "runtime_mappings": {
    "measure": {
      "type": "long",
      "script": {
        "lang": "painless",
        "source": "emit(doc['measure'].value * params.factor);",
        "params": {
          "factor": 2
        }
      }
    }
  }
}

Changes in PR

  • Add lang field to RuntimeField
  • Add params field to RuntimeField
  • Add unit tests
  • Make RuntimeField return this to allow calls being chained and to make the it consistent with the rest of the API, as suggested on this comment.

@sudo-suhas
Copy link
Owner

@alejokf could you please resolve conflicts add tests to ensure 100% coverage? We need tests for the following:

@alejokf
Copy link
Contributor Author

alejokf commented May 6, 2024

@sudo-suhas conflicts are now fixed and coverage should be 100%

@sudo-suhas sudo-suhas merged commit 7150119 into sudo-suhas:master Oct 30, 2024
2 checks passed
@sudo-suhas
Copy link
Owner

I am very sorry for having missed merging this for so long 🙇🏼‍♂️ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support lang and params in RuntimeField script for runtime_mappings
2 participants